package com.jjyu.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.jjyu.dao.FavoriteRestaurantMapper;
import com.jjyu.entity.FavoriteRestaurant;
import com.jjyu.service.FavoriteRestaurantService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class FavoriteRestaurantServiceImpl extends ServiceImpl<FavoriteRestaurantMapper, FavoriteRestaurant> implements FavoriteRestaurantService {

    @Autowired
    private FavoriteRestaurantMapper favoriteRestaurantMapper;

    @Override
    public boolean addFavoriteRestaurant(FavoriteRestaurant favoriteRestaurant) {
        return favoriteRestaurantMapper.addFavoriteRestaurant(favoriteRestaurant) > 0;
    }

    @Override
    public boolean deleteFavoriteRestaurant(Integer favoriteId) {
        return favoriteRestaurantMapper.deleteFavoriteRestaurant(favoriteId) > 0;
    }

    @Override
    public boolean updateFavoriteRestaurant(FavoriteRestaurant favoriteRestaurant) {
        return favoriteRestaurantMapper.updateFavoriteRestaurant(favoriteRestaurant) > 0;
    }

    @Override
    public List<FavoriteRestaurant> findFavoriteRestaurantsByUserId(Integer userId) {
        return favoriteRestaurantMapper.findByUserId(userId);
    }
}

